<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <style type="text/css">
            .col-label {
                width: 100px;
                text-align: right;
            }

            .col-input {
            }
        </style>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                }
            }

            function doPopupWindow(obj) {
                var pkid = obj.parentNode.parentNode.parentNode.childNodes[0].childNodes[0].childNodes[0].innerHTML;
                popupwindow = window.open("interview.xhtml?action=interview&amp;pkid=" + pkid, "popupwindow", "height=600,width=800,left=200,top=100,toolbar=no,menubar=no,scrollbars=yes,location=no");
                popupwindow.focus;
            }

            function closeThisWindow(rtnflag) {
                if (rtnflag == "true") {
                    window.returnValue = "1";
                    window.close();
                }
            }

        </script>
    </ui:define>

    <ui:define name="content">
        <div style="margin:5px;">
            <p:growl id="msgs" showDetail="false"/>
            <h:form id="form">
                <h:outputText id="jscript" escape="false" value="#{interviewAction.jscript}"/>
                <p:panel header="【客户基本信息】">
                    <h:panelGrid columns="1" cellspacing="5" columnClasses="col-80">
                        <h:panelGrid columns="4" cellspacing="5"
                                     columnClasses="col-label,col-input,col-label,col-input">
                            <h:outputLabel value="客户编号:" for="custno"/>
                            <h:inputText id="custno" size="30" disabled="true" readonly="true"
                                         value="#{interviewAction.crmCustomer.custno}"/>
                            <h:outputLabel value="客户名称:" for="custname"/>
                            <h:inputText id="custname" size="30" disabled="true" readonly="true"
                                         value="#{interviewAction.crmCustomer.custname}"/>
                            <h:outputLabel value="经理姓名:" for="managerName"/>
                            <h:inputText id="managerName" size="30" disabled="true" readonly="true"
                                         value="#{interviewAction.crmCustomer.managerName}"/>
                            <h:outputLabel value="联系电话:" for="managerPhone1"/>
                            <h:inputText id="managerPhone1" size="30" disabled="true" readonly="true"
                                         value="#{interviewAction.crmCustomer.managerPhone1}"/>

                            <h:outputLabel value="贷款方式:" for="loanType"/>
                            <p:selectOneMenu id="loanType" style="width:190px;" value="#{interviewAction.crmLoanInfo.loanType}">
                                <f:selectItem itemValue="00" itemLabel="暂时无意向"/>
                                <f:selectItems value="#{interviewAction.loanTypes}"/>
                            </p:selectOneMenu>

                            <h:outputLabel value="融资金额:" for="loanAmt"/>
                            <h:inputText id="loanAmt" size="30" maxlength="19"
                                         converterMessage="融资金额格式错误！"
                                         value="#{interviewAction.crmLoanInfo.loanAmt}">
                                <f:convertNumber pattern="###,##0.00"/>
                            </h:inputText>

                            <h:outputLabel value="访谈结果:" for="interResult"/>
                            <p:selectOneMenu id="interResult" style="width:190px;" value="#{interviewAction.crmLoanInfo.interResult}">
                                <f:selectItems value="#{interviewAction.interviewResults}"/>
                                <p:ajax update="reasons" listener="#{interviewAction.handleResultChange}"/>
                            </p:selectOneMenu>

                            <h:outputLabel value="拒绝原因:" for="reasons"/>
                            <p:selectOneMenu id="reasons" style="width:190px;" value="#{interviewAction.crmLoanInfo.interReason}">
                                <f:selectItems value="#{interviewAction.refuseReasons}"/>
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="2">
                            <h:outputLabel value="访谈备注:" for="remark" style="margin-left: 55px;" styleClass="col-label"/>
                            <p:inputTextarea id="remark" maxLength="50" value="#{interviewAction.crmLoanInfo.remark}"
                                             style="width:493px;height:100px;"
                                             effectDuration="400"/>
                        </h:panelGrid>

                        <h:panelGrid columns="2">
                            <p:commandButton id="saveBtn" style="margin-left:302px;" value="保存"
                                             action="#{interviewAction.onSave}"
                                             update="msgs,form,pdt">
                            </p:commandButton>
                            <p:commandButton id="clsBtn" style="margin-left:10px;" value="关闭"
                                             onclick="window.close();"/>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:panel>

                <p:ajaxStatus style="height:18px;text-align:center">
                    <f:facet name="start">
                        <h:graphicImage value="/images/ajaxloadingbar.gif"/>
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value=""/>
                    </f:facet>
                </p:ajaxStatus>
                <p:dataTable id="pdt" style="width:100%;align:center;"
                             value="#{interviewAction.loanInfoList}" var="record"
                             rowKey="#{record.custPkid}"
                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             paginator="true" rows="15" paginatorPosition="bottom"
                             rowsPerPageTemplate="100,50,30,15,5"
                             emptyMessage="数据记录为空...">
                    <p:column headerText="客户编号" >
                        <h:outputText value="#{record.custNo}" style="text-align:left;"/>
                    </p:column>
                    <p:column headerText="客户名称" >
                        <h:outputText value="#{record.custName}" style="text-align:left;"/>
                    </p:column>
                    <p:column headerText="贷款方式" >
                        <h:outputText value="#{interviewAction.loanKVTypes[record.loanType]}" style="text-align:left;"/>
                    </p:column>
                    <p:column headerText="融资金额" style="text-align:right;">
                        <h:outputText value="#{record.loanAmt}" style="text-align:right;">
                                <f:convertNumber pattern="###,##0.00"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="访谈结果" >
                        <h:outputText value="#{interviewAction.interviewKVResults[record.interResult]}" style="text-align:left"/>
                    </p:column>
                    <p:column headerText="拒绝原因">
                        <h:outputText value="#{interviewAction.refuseKVReasons[record.interReason]}" style="text-align:left"/>
                    </p:column>
                    <p:column headerText="访谈时间" style="text-align:center;">
                        <h:outputText value="#{record.txndate} #{record.txntime}" />
                    </p:column>

                    <p:column headerText="访谈人" >
                        <h:outputText value="#{record.operid}" style="text-align:left"/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </div>
    </ui:define>

</ui:composition>